import React, { useState, useCallback } from 'react'

export default function CallbackHookDemo01() {

  const [count, setCount] = useState(0)

  const incremt = () => { 
    setCount(count + 1)
    console.log("aaa");
  }

    const incremt2 = useCallback(() => {
      setCount(count + 1);
      console.log("aaa");
    }, [count]);

  return (
    <div>
      <h2>CallbackHookDemo01：{count}</h2>
      <button onClick={incremt}>+1</button>
      <button onClick={incremt2}>+1</button>
    </div>
  );
}
